import { combineReducers } from 'redux';

import {
    SET_NAME,
    ADD_POST,
} from './actions';

const NameStore = (state = {
    name: 'default',
}, action) => {
    switch (action.type) {
    case SET_NAME:
        return {
            name: action.name,
        }
    default:
        return state
    }
};

const PostState = (state = {
    posts: [],
}, action) => {
    switch (action.type) {
        case ADD_POST:
            return {
                ...state,
                posts: state.posts.concat(action.post),
            }
        default:
            return state
    }
};


const rootReducer = combineReducers({
 NameStore,
    PostState
})
  
export default rootReducer